package org.carabiner.infinitest.depgraph;

import java.util.List;
import java.util.regex.Pattern;

import junit.framework.TestCase;

import org.carabiner.infinitest.FilterList;

public class RegexVerifier implements TestVerifier
{
  private FilterList filters;
  private TestVerifier testCaseVerifier;
  
  public RegexVerifier(FilterList filterList)
  {    
    filters = filterList;
    testCaseVerifier = new TestCaseVerifier();
  }

  private boolean isATestCase(Class clazz)
  {
    if (clazz == null)
      return false;
    if (TestCase.class.equals(clazz.getSuperclass()))
      return true;
    return isATestCase(clazz.getSuperclass());
  }
  
  public boolean isATest(Class clazz)
  {    
    if (!isATestCase(clazz))
    {
      return false;
    }    
    if (filters.match(clazz.getName()))
    {      
      return false;
    }
    return true;
  }

  public boolean isFiltered(String name)
  {
    return filters.match(name);    
  }
}
